<script lang="ts" setup>
	import { ref, defineProps } from "vue";
	// import { onUnload } from "@dcloudio/uni-app";
	// onUnload(() => {
	// 	uni.navigateTo({
	// 		url: "/pages/home/index",
	// 	});
	// })
	const props = defineProps({
		tabbar: {
			type: Number,
			default: 0,
			required: true
		}
	})
	const tabbar = ref(props.tabbar)
	const change = (res) => {
		tabbar.value = res
		if (res == 0) {
			uni.reLaunch({
				url: "/pages/home/index",
			});
		} else if (res == 1) {
			uni.navigateTo({
				url: "/pages/order/index",
			});
		} else if (res == 2) {
			uni.reLaunch({
				url: "/pages/my/index",
			});

		}
		console.log(res, '点击');
	}
</script>
<template>
	<view>
		<uv-tabbar :value="tabbar" @change="change" :fixed="true">
			<uv-tabbar-item text="首页" icon="home"></uv-tabbar-item>
			<!-- <uv-tabbar-item text="商品" icon="gift"></uv-tabbar-item> -->
			<uv-tabbar-item text="消息" icon="chat"></uv-tabbar-item>
			<uv-tabbar-item text="福利中心" icon="gift"></uv-tabbar-item>
			<!-- <uv-tabbar-item text="代理" icon="integral"></uv-tabbar-item> -->
			<uv-tabbar-item text="我的" icon="account"></uv-tabbar-item>
		</uv-tabbar>
	</view>
</template>
<style lang="scss" scoped></style>